﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using aspnet_test_lib;
using System.Diagnostics;

namespace WebApplication1Test
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void CanOpenIndexPage()
        {
            AspNetTestBrowser browser = new AspNetTestBrowser();
            browser.Open("http://localhost:50002/Index.aspx");

            Assert.IsTrue(browser.PageHtml.Contains("Index"));
        }

        [TestMethod]
        public void CanRedirectNewAccountPage()
        {
            AspNetTestBrowser browser = new AspNetTestBrowser();
            browser.Open("http://localhost:50002/Index.aspx");

            Dictionary<string, string> parms = new Dictionary<string, string>();
            parms.Add(AspHiddenField.EVENTTARGET, "lnkNewAccount");
            parms.Add(AspHiddenField.EVENTARGUMENT, string.Empty);
            browser.Postback(parms);

            Assert.IsTrue(browser.PageHtml.Contains("Create New Account"));
            
        }

        [TestMethod]
        public void CanRedirectCategoryPage()
        {
            AspNetTestBrowser browser = new AspNetTestBrowser();
            browser.Open("http://localhost:50002/Index.aspx");


            Dictionary<string, string> parms = new Dictionary<string, string>();
            parms.Add("txtCategoryID", "5");
            parms.Add("btnQueryCategory", "Query Category");
            browser.Postback(parms);

            Debug.WriteLine(browser.PageHtml);
            Assert.IsTrue(browser.PageHtml.Contains("Categories"));
        }
    }
}
